package rcs34.android.libs.HSVOPicker;

import android.os.Handler;

public class PickerMover extends Thread{
  private ColorPicker picker;
  private boolean stopped=false;
  private int direction;
  private Handler handler;
  public PickerMover(ColorPicker _picker, int _direction, Handler _handler){
    picker=_picker;
    direction=_direction*3;
    handler=_handler;
  }
  @Override
  public void run(){
    try {
      sleep(1000);
    } catch (InterruptedException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    while(!stopped){
      try {
        sleep(200);
      } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
      if(!stopped){
      handler.post(new Runnable(){
        public void run(){
        picker.step(direction);}
      });
      }
    }
  }
  
  public void stopWork(){
    stopped=true;
  }
}
